<template>
    <view class="page-login-phone page-login-index">
        <view class="bg">
            <u-image :src="proxy.$icon.logo" shape="circle" width="200rpx" height="200rpx" />
            <view class="name">方圆汇</view>
            <view class="subtitle">欢迎您</view>
        </view>
        <view class="m-4" v-if="v">
            <u-button class="btn-cyan-gradient" text="登录" @click="wxLogin">快速登录</u-button>
            <view class="p-4 c-grey9 text-center" @click="proxy.$util.gotoPage('/pages/register/index')">没账号？去注册</view>
        </view>
        <account-login v-else />      
    </view>
</template>
<script setup lang="ts">
import { onShow } from '@dcloudio/uni-app';
import AccountLogin from './account';
import { useAppStore } from '@/stores/app';
const appStore = useAppStore();
const {proxy} = getCurrentInstance() as ComponentInternalInstance;
let v = ref(false);
const wxLogin = async () => {
    appStore.wxLogin().then(res => {
        let url = uni.getStorageSync('beforeLogin');
        if(url){
            // proxy.$util.gotoPage(url)
            uni.reLaunch({
                url: url
            });
        }else{
            uni.reLaunch({
                url: '/pages/home/index'
            })
        }
    });
}
onShow(() => {
    v.value = appStore.versionStatus;
})
</script> 